package com.qinchen.service;

import com.qinchen.spring.*;

/**
 * @author 钦尘
 * @date 2021/9/30 5:53
 * @description TODO
 */
@Scope("singleton")
@Component("userService")
public class UserServiceImpl implements IUserService, InitializingBean, BeanNameAware {

    @Autowired
    private OrderService orderService;

    /**
     * 模拟通过 BeanNameAware 回调 给赋值
     */
    private String beanName;

    @Override
    public String login() {

        System.out.println("执行登录逻辑");

        System.out.println("userService的orderService属性值为：" + orderService);

        System.out.println("通过BeanNameAware，得到当前beanName = " + beanName);

        return "login success";
    }

    @Override
    public void afterPropertiesSet() {
        System.out.println("扩展点：初始化后，可继续做点什么");
    }

    @Override
    public void setBeanName(String beanName) {
        this.beanName = beanName;
    }
}
